//
//  DetailViewController.m
//  豆瓣YHY
//
//  Created by dllo on 15/10/31.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "MovieDetailViewController.h"
#import "MovieDetailView.h"
#import "AppTools.h"
#import "SDImageCache.h"
#import "UIImageView+WebCache.h"
#import "MBProgressHUD.h"
@interface MovieDetailViewController ()

@property (nonatomic,retain)MBProgressHUD *hub;

@end

@implementation MovieDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blueColor];
    MovieDetailView *moDV = [[MovieDetailView alloc]init];
    [self.view addSubview:moDV];
    NSLog(@"fgfvf");
 //   moDV.ratingLabel.text = self.movieb.rating ;
 //   moDV.release_dateLabel.text = self.movieb.release_date;
  //  moDV.
    self.hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [self.hub show:YES];
    self.hub.labelText = @"正在加载";
    
   
    NSString *urlStr = [NSString stringWithFormat:@"http://project.lanou3g.com/teacher/yihuiyun/lanouproject/searchmovie.php?movieId=%@",self.movieb.movieId];
    
       NSLog(@"self.movieID-- %@", self.movieb.movieId);
    NSLog(@"--- %@", urlStr);
  
    [AppTools getLocalDataWithURL:urlStr andBlock:^(id dic) {
        
        
//        NSMutableDictionary *dic= result;//新字典里存储大的数据，result有可能是数组或者字典
//        NSLog(@"dic = %@,",dic);
//        NSDictionary *resultDic =[dic objectForKey:@"result"];//找出字典里对用的数据
//        self.nameLabel.text = [resultDic objectForKey:@"title"];
//        NSURL *url = [NSURL URLWithString:[resultDic objectForKey:@"poster"]];
//        [self.headImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"/Users/dllo/Desktop/UI/UI_16_豆瓣/UI_16_豆瓣/placeHoderImage.png"]];

        
        NSMutableDictionary *dica = dic;
        NSLog(@"dic =%@",dic);
        NSMutableDictionary *resultDic = [dica objectForKey:@"result"];
        //
        self.navigationItem.title = [resultDic objectForKey:@"title"];

        Movie *movie = [[Movie alloc] init];
        [movie setValuesForKeysWithDictionary:resultDic];
        
        moDV.movie = movie;
        NSURL *url = [NSURL URLWithString:[resultDic objectForKey:@"poster"]];
                [moDV.pic_url sd_setImageWithURL:url];
        
        
        
        
        moDV.plot_simpleLabel.text = [resultDic objectForKey:@"plot_simple"];
        moDV.actorsLabel.text = [resultDic objectForKey:@"actors"];
        moDV.country.text = [resultDic objectForKey:@"country"];
        moDV.genresLabel.text = [resultDic objectForKey:@"genres"];
        moDV.runtimeLabel.text =[resultDic objectForKey:@"runtime"];
        moDV.release_dateLabel.text = [resultDic objectForKey:@"release_date"];
     moDV.ratingLabel.text= [resultDic objectForKey:@"rating"];
//        NSURL *url = [NSURL URLWithString:[resultDic objectForKey:@"poster"]];
//        [moDV.pic_url sd_setImageWithURL:url];
//        [self.hub hide:YES];
    }];
    
    //NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
